package com.study_online.config;

import com.study_online.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public LoginInterceptor getLoginInterceptor(){
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] path = {"/**"};
        String[] rexcludePath = {"/user/login","/user/sendEmail","/user/register","/videoType/**",
                "/Video/**","/alipay/**","/erro","/user/selectHomeVideo","/user/adminNotice",
                "/search/searchByKeywords"};
        registry.addInterceptor(getLoginInterceptor()).addPathPatterns(path).excludePathPatterns(rexcludePath);
    }
}
